package pe.com.bn.sach.dao.impl;

import java.util.List;
import com.ibatis.sqlmap.client.SqlMapClient;


import pe.com.bn.sach.dao.PolizaDAO;


import pe.com.bn.sach.domain.Bnchf61Poliza;

import org.apache.log4j.Logger;

public class PolizaImpl  implements PolizaDAO 
{

	
	 private static Logger log = Logger.getLogger(PolizaImpl.class.getName());
	 
	protected SqlMapClient sqlMap = null;
	
	public void setSqlMap(SqlMapClient sqlMap) {
		this.sqlMap = sqlMap;
	}
	
	public void ActualizaPoliza(Bnchf61Poliza bnchf61Poliza) throws Exception{
		
	try{
			sqlMap.startTransaction();
			sqlMap.update("sqlPoliza.ActualizaPoliza",bnchf61Poliza);
			sqlMap.commitTransaction();
		}catch(Exception e){
			e.printStackTrace();
			throw e;
		}finally{
			sqlMap.endTransaction();
		}
    	
    }
	
	
	public void GuardaPoliza(Bnchf61Poliza bnchf61Poliza) throws Exception{
	

		
		try{
			sqlMap.startTransaction();
			sqlMap.insert("sqlPoliza.GuardaPoliza",bnchf61Poliza);
			sqlMap.commitTransaction();
		}catch(Exception e){
			e.printStackTrace();
			throw e;
		}finally{
			sqlMap.endTransaction();
		}
		
		
		
    }
	
	public Bnchf61Poliza buscarPoliza(Bnchf61Poliza bnchf61Poliza) throws Exception{

		List l = sqlMap.queryForList("sqlPoliza.buscarPoliza",bnchf61Poliza);
		bnchf61Poliza = (Bnchf61Poliza)l.get(0);
		return  bnchf61Poliza ;
	}
	
}
